﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace syc.Juece.Report
{
    public partial class 月份入库量统计快报 : System.Web.UI.Page
    {
        protected HSSFWorkbook hssfworkbook;

        
        protected double 一分厂年计划 = 0;
        protected double 二分厂年计划 = 0;
        protected double 五分厂年计划 = 0;
        protected double 一分厂月计划 = 0;
        protected double 二分厂月计划 = 0;
        protected double 五分厂月计划 = 0;

        protected double nyoujihua = 0;//年油管计划  
        protected double ntaojihua = 0;//年套管计划
        protected double nyjiegujihua = 0;//年油管接箍计划
        protected double ntjiegujihua = 0;//年套管接箍计划
        protected double nbaohuqijihua = 0;//年保护器计划

        protected double yyoujihua = 0;//月油管计划  
        protected double ytaojihua = 0;//月套管计划
        protected double yyjiegujihua = 0;//月油管接箍计划
        protected double ytjiegujihua = 0;//月套管接箍计划
        protected double ybaohuqijihua = 0;//月保护器计划

        protected double y2you = 0;//二分厂月油管
        protected double y5you = 0;//五分厂月油管
        protected double y1tao = 0;//一分厂月套管
        protected double y2tao = 0;//二分厂月套管
        protected int y3yjiegu = 0;//三分厂月油管接箍
        protected int y3tjiegu = 0;//三分厂月套管接箍
        protected int y4baohuqi = 0;//四分厂月保护器
        protected double ytao = 0;//月套管
        protected double yyou = 0;//月油管
        protected int yyjiegu = 0;//月油管接箍
        protected int ytjiegu = 0;//月套管接箍
        protected int ybaohuqi = 0;//月保护器

        protected double n2you = 0;//二分厂月油管
        protected double n5you = 0;//五分厂月油管
        protected double n1tao = 0;//一分厂月套管
        protected double n2tao = 0;//二分厂月套管
        protected int n3yjiegu = 0;//三分厂月油管接箍
        protected int n3tjiegu = 0;//三分厂月套管接箍
        protected int n4baohuqi = 0;//四分厂月保护器
        protected double ntao = 0;//月套管
        protected double nyou = 0;//月油管
        protected int nyjiegu = 0;//月油管接箍
        protected int ntjiegu = 0;//月套管接箍
        protected int nbaohuqi = 0;//月保护器

        protected double 油套管月完成率 = 0;
        protected double 油管月完成率 = 0;
        protected double 套管月完成率 = 0;
        protected double 一分厂月完成率 = 0;
        protected double 二分厂月完成率 = 0;
        protected double 五分厂月完成率 = 0;
        protected double 套管接箍月完成率 = 0;
        protected double 油管接箍月完成率 = 0;
        protected double 保护器月完成率 = 0;

        protected double 油套管年完成率 = 0;
        protected double 油管年完成率 = 0;
        protected double 套管年完成率 = 0;
        protected double 一分厂年完成率 = 0;
        protected double 二分厂年完成率 = 0;
        protected double 五分厂年完成率 = 0;
        protected double 套管接箍年完成率 = 0;
        protected double 油管接箍年完成率 = 0;
        protected double 保护器年完成率 = 0;
        protected int year;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Month.SelectedValue=DateTime.Today.Month.ToString();
                this.Year0.Text = DateTime.Today.Year.ToString();
            }
        }
        protected void WriteToFile()
        {
            DateTime d;

            d = DateTime.Today;

            Response.ContentType = "application/ms-excel";
            Response.AddHeader("content-disposition", "attachment; filename=\"" + d.ToShortDateString() + ".xls\"");
            hssfworkbook.Write(Response.OutputStream);
        }
        protected void InitializeWorkbook()
        {

            FileStream file = new FileStream(HttpContext.Current.Server.MapPath("/JueCe/模板/月份入库量统计快报.xls"), FileMode.Open, FileAccess.Read);

            hssfworkbook = new HSSFWorkbook(file);

            DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation();
            dsi.Company = "陕西延长石油材料有限公司";
            hssfworkbook.DocumentSummaryInformation = dsi;

            SummaryInformation si = PropertySetFactory.CreateSummaryInformation();
            si.Subject = "报表";
            si.Title = "陕西延长石油材料公司月份入库量统计快报";
            hssfworkbook.SummaryInformation = si;
        }
        protected void Button_Query_Click(object sender, EventArgs e)
        {
            year = int.Parse(this.Year0.Text);
            SqlConnection Conn = new SqlConnection();
            Conn.ConnectionString = ConfigurationManager.ConnectionStrings["SCMConnectionString1"].ConnectionString;
            Conn.Open();
            SqlCommand Cmd = new SqlCommand();
            Cmd.Connection = Conn;
            //获得年计划
            Cmd.CommandText = @"select (isnull(二分厂产品1,0)+isnull(五分厂产品1,0)) as 月油管计划,(isnull(一分厂产品2,0)+isnull(二分厂产品2,0)) as 月套管计划,isnull(一分厂产品2,0) as 一分厂,(isnull(二分厂产品1,0)+isnull(二分厂产品2,0)) as 二分厂,isnull(五分厂产品1,0) as 五分厂,isnull(三分厂产品1,0) as 月油管接箍,isnull(三分厂产品2,0) as 月套管接箍,isnull(四分厂产品2,0) as 月保护器 from 生产计划 where 年度='" + year + "' and 月份=0";
            SqlDataReader Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                nyoujihua = Reader.GetDouble(0);
                ntaojihua = Reader.GetDouble(1);
                一分厂年计划 = Reader.GetDouble(2);
                二分厂年计划 = Reader.GetDouble(3);
                五分厂年计划 = Reader.GetDouble(4);
                nyjiegujihua = Reader.GetDouble(5);
                ntjiegujihua = Reader.GetDouble(6);
                nbaohuqijihua = Reader.GetDouble(7);
            }
            Reader.Close();
            //获得月计划
            Cmd.CommandText = @"select (isnull(二分厂产品1,0)+isnull(五分厂产品1,0)) as 月油管计划,(isnull(一分厂产品2,0)+isnull(二分厂产品2,0)) as 月套管计划,isnull(一分厂产品2,0) as 一分厂,(isnull(二分厂产品1,0)+isnull(二分厂产品2,0)) as 二分厂,isnull(五分厂产品1,0) as 五分厂,isnull(三分厂产品1,0) as 月油管接箍,isnull(三分厂产品2,0) as 月套管接箍,isnull(四分厂产品2,0) as 月保护器 from 生产计划 where 年度='" + year + "' and 月份='"+this.Month.Text+"'";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                yyoujihua = Reader.GetDouble(0);
                ytaojihua = Reader.GetDouble(1);
                一分厂月计划 = Reader.GetDouble(2);
                二分厂月计划 = Reader.GetDouble(3);
                五分厂月计划 = Reader.GetDouble(4);
                yyjiegujihua = Reader.GetDouble(5);
                ytjiegujihua = Reader.GetDouble(6);
                ybaohuqijihua = Reader.GetDouble(7);
            }
            Reader.Close();
            //二分厂月油管量          
            Cmd.CommandText = @"
            declare @yc smalldatetime
            declare @ym smalldatetime
            select @yc=起始日期,@ym=截止日期 from 生产月设置
            where 分厂=2 and 年度='" + year + "' and 月份='" + this.Month.Text + "' select isnull(sum(入库重量),0)/1000 from 生产进度 where 分厂ID=2 and 产品类别ID=1 and 日期 between @yc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                y2you = Reader.GetDouble(0);
            }
            Reader.Close();
            //五分厂月油管
            Cmd.CommandText = @"
            declare @yc smalldatetime
            declare @ym smalldatetime
            select @yc=起始日期,@ym=截止日期 from 生产月设置
            where 分厂=5 and 年度='" + year + "' and 月份='" + this.Month.Text + "' select isnull(sum(入库重量),0)/1000 from 生产进度 where 分厂ID=5 and 产品类别ID=1 and 日期 between @yc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                y5you = Reader.GetDouble(0);
            }
            //月油管
            yyou = y2you + y5you;
            Reader.Close();
            //一分厂月套管量
            Cmd.CommandText = @"
            declare @yc smalldatetime
            declare @ym smalldatetime
            select @yc=起始日期,@ym=截止日期 from 生产月设置
            where 分厂=1 and 年度='" + year + "' and 月份='" + this.Month.Text + "' select isnull(sum(入库重量),0)/1000 from 生产进度 where 分厂ID=1 and 产品类别ID=2 and 日期 between @yc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                y1tao = Reader.GetDouble(0);
            }
            Reader.Close();
            //二分厂月套管量
            Cmd.CommandText = @"
            declare @yc smalldatetime
            declare @ym smalldatetime
            select @yc=起始日期,@ym=截止日期 from 生产月设置
            where 分厂=2 and 年度='" + year + "' and 月份='" + this.Month.Text + "' select isnull(sum(入库重量),0)/1000 from 生产进度 where 分厂ID=2 and 产品类别ID=2 and 日期 between @yc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                y2tao = Reader.GetDouble(0);
            }
            Reader.Close();
            //月套管
            ytao = y1tao + y2tao;
            //三分厂月油管接箍量
            Cmd.CommandText = @"
            declare @yc smalldatetime
            declare @ym smalldatetime
            select @yc=起始日期,@ym=截止日期 from 生产月设置
            where 分厂=3 and 年度='" + year + "' and 月份='" + this.Month.Text + "' select isnull(sum(磷化支数),0) from 生产进度3 where 产品类别ID=1 and 日期 between @yc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                y3yjiegu = Reader.GetInt32(0);
            }
            Reader.Close();
            //三分厂月套管接箍量
            Cmd.CommandText = @"
            declare @yc smalldatetime
            declare @ym smalldatetime
            select @yc=起始日期,@ym=截止日期 from 生产月设置
            where 分厂=3 and 年度='" + year + "' and 月份='" + this.Month.Text + "' select isnull(sum(磷化支数),0) from 生产进度3 where 产品类别ID=2 and 日期 between @yc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                y3tjiegu = Reader.GetInt32(0);
            }
            Reader.Close();
            yyjiegu = int.Parse(y3yjiegu.ToString());
            ytjiegu = int.Parse(y3tjiegu.ToString());
            //四分厂月保护器
            Cmd.CommandText = @"
            declare @yc smalldatetime
            declare @ym smalldatetime
            select @yc=起始日期,@ym=截止日期 from 生产月设置
            where 分厂=4 and 年度='" + year + "' and 月份='" + this.Month.Text + "' select isnull(sum(入库),0) from 生产进度4 where 产品类别ID=2 and 日期 between @yc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                y4baohuqi = Reader.GetInt32(0);
            }
            Reader.Close();
            ybaohuqi = int.Parse(y4baohuqi.ToString());


            //二分厂年油管量          
            Cmd.CommandText = @"
            declare @nc smalldatetime
            declare @ym smalldatetime
            select @nc=起始日期 from 生产月设置 where 年度='" + year + "' and 月份='1'and 分厂=2 select @ym=截止日期 from 生产月设置 where 年度='" + year + "' and 月份='" + this.Month.Text + "' and 分厂=2 select isnull(sum(入库重量),0)/1000 from 生产进度 where 分厂ID=2 and 产品类别ID=1 and 日期 between @nc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                n2you = Reader.GetDouble(0);
            }
            Reader.Close();
            //五分厂年油管
            Cmd.CommandText = @"
            declare @nc smalldatetime
            declare @ym smalldatetime
            select @nc=起始日期 from 生产月设置 where 年度='" + year + "' and 月份='1'and 分厂=5 select @ym=截止日期 from 生产月设置 where 年度='" + year + "' and 月份='" + this.Month.Text + "' and 分厂=5 select isnull(sum(入库重量),0)/1000 from 生产进度 where 分厂ID=5 and 产品类别ID=1 and 日期 between @nc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                n5you = Reader.GetDouble(0);
            }
            //年油管
            nyou = n2you + n5you;
            Reader.Close();
            //一分厂年套管量
            Cmd.CommandText = @"
            declare @nc smalldatetime
            declare @ym smalldatetime
            select @nc=起始日期 from 生产月设置 where 年度='" + year + "' and 月份='1'and 分厂=1 select @ym=截止日期 from 生产月设置 where 年度='" + year + "' and 月份='" + this.Month.Text + "' and 分厂=1 select isnull(sum(入库重量),0)/1000 from 生产进度 where 分厂ID=1 and 产品类别ID=2 and 日期 between @nc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                n1tao = Reader.GetDouble(0);
            }
            Reader.Close();

            //二分厂年套管量
            Cmd.CommandText = @"
            declare @nc smalldatetime
            declare @ym smalldatetime
            select @nc=起始日期 from 生产月设置 where 年度='" + year + "' and 月份='1'and 分厂=2 select @ym=截止日期 from 生产月设置 where 年度='" + year + "' and 月份='" + this.Month.Text + "' and 分厂=2 select isnull(sum(入库重量),0)/1000 from 生产进度 where 分厂ID=2 and 产品类别ID=2 and 日期 between @nc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                n2tao = Reader.GetDouble(0);
            }
            Reader.Close();
            //年套管
            ntao = n1tao + n2tao;
            //三分厂年油管接箍量
            Cmd.CommandText = @"
            declare @nc smalldatetime
            declare @ym smalldatetime
            select @nc=起始日期 from 生产月设置 where 年度='" + year + "' and 月份='1'and 分厂=3 select @ym=截止日期 from 生产月设置 where 年度='" + year + "' and 月份='" + this.Month.Text + "' and 分厂=3 select isnull(sum(磷化支数),0) from 生产进度3 where  产品类别ID=1 and 日期 between @nc and @ym";
            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                n3yjiegu = Reader.GetInt32(0);
            }
            Reader.Close();
            //三分厂年套管接箍量
            Cmd.CommandText = @"
            declare @nc smalldatetime
            declare @ym smalldatetime
            select @nc=起始日期 from 生产月设置 where 年度='" + year + "' and 月份='1'and 分厂=3 select @ym=截止日期 from 生产月设置 where 年度='" + year + "' and 月份='" + this.Month.Text + "' and 分厂=3 select isnull(sum(磷化支数),0) from 生产进度3 where  产品类别ID=2 and 日期 between @nc and @ym";

            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                n3tjiegu = Reader.GetInt32(0);
            }
            Reader.Close();
            nyjiegu = int.Parse(n3yjiegu.ToString());
            ntjiegu = int.Parse(n3tjiegu.ToString());
            //四分厂年保护器
            Cmd.CommandText = @"
            declare @nc smalldatetime
            declare @ym smalldatetime
            select @nc=起始日期 from 生产月设置 where 年度='" + year + "' and 月份='1'and 分厂=4 select @ym=截止日期 from 生产月设置 where 年度='" + year + "' and 月份='" + this.Month.Text + "' and 分厂=4 select isnull(sum(入库),0) from 生产进度4 where 产品类别ID=2 and 日期 between @nc and @ym";

            Reader = Cmd.ExecuteReader();
            if (Reader.Read())
            {
                n4baohuqi = Reader.GetInt32(0);
            }
            Reader.Close();
            nbaohuqi = int.Parse(n4baohuqi.ToString());
            if ((ytaojihua + yyoujihua) == 0)
            {
                油套管月完成率 = 0;
            }
            else
            {
                油套管月完成率 = ((yyou + ytao) / (ytaojihua + yyoujihua))*100;
            }
            if (yyoujihua == 0)
            {
                油管月完成率 = 0;
            }else{
                油管月完成率 = (yyou / yyoujihua)*100;
            }
            if (ytaojihua == 0)
            {
                套管月完成率 = 0;
            }
            else
            {
                套管月完成率 = (ytao / ytaojihua)*100;
            }
            if (一分厂月计划 == 0)
            {
                一分厂月完成率 = 0;
            }
            else
            {
                一分厂月完成率 = (y1tao / 一分厂月计划)*100;
            }
            if (二分厂月计划 == 0)
            {
                二分厂月完成率 = 0;
            }
            else
            {
                二分厂月完成率 = ((y2you + y2tao) / 二分厂月计划)*100;
            }
            if (五分厂月计划 == 0)
            {
                五分厂月完成率 = 0;
            }
            else
            {
                五分厂月完成率 = (y5you / 五分厂月计划)*100;
            }
            if (ytjiegujihua == 0)
            {
                套管接箍月完成率 = 0;
            }
            else
            {
                套管接箍月完成率 = (ytjiegu / ytjiegujihua)*100;
            }
            if (yyjiegujihua == 0)
            {
                油管接箍月完成率 = 0;
            }
            else
            {
                油管接箍月完成率 = (yyjiegu / yyjiegujihua)*100;
            }
            if (ybaohuqijihua == 0)
            {
                保护器月完成率 = 0;
            }
            else
            {
                保护器月完成率 = (ybaohuqi / ybaohuqijihua)*100;
            }

            //------------------------------------------------------------

            if ((ntaojihua + nyoujihua) == 0)
            {
                油套管年完成率 = 0;
            }
            else
            {
                油套管年完成率 = ((nyou + ntao) / (ntaojihua + nyoujihua)) * 100;
            }
            if (nyoujihua == 0)
            {
                油管年完成率 = 0;
            }
            else
            {
                油管年完成率 = (nyou / nyoujihua) * 100;
            }
            if (ntaojihua == 0)
            {
                套管年完成率 = 0;
            }
            else
            {
                套管年完成率 = (ntao / ntaojihua) * 100;
            }
            if (一分厂年计划 == 0)
            {
                一分厂年完成率 = 0;
            }
            else
            {
                一分厂年完成率 = (n1tao / 一分厂年计划) * 100;
            }
            if (二分厂年计划 == 0)
            {
                二分厂年完成率 = 0;
            }
            else
            {
                二分厂年完成率 = ((n2you + n2tao) / 二分厂年计划) * 100;
            }
            if (五分厂年计划 == 0)
            {
                五分厂年完成率 = 0;
            }
            else
            {
                五分厂年完成率 = (n5you / 五分厂年计划) * 100;
            }
            if (ntjiegujihua == 0)
            {
                套管接箍年完成率 = 0;
            }
            else
            {
                套管接箍年完成率 = (ntjiegu / ntjiegujihua) * 100;
            }
            if (nyjiegujihua == 0)
            {
                油管接箍年完成率 = 0;
            }
            else
            {
                油管接箍年完成率 = (nyjiegu / nyjiegujihua) * 100;
            }
            if (nbaohuqijihua == 0)
            {
                保护器年完成率 = 0;
            }
            else
            {
                保护器年完成率 = (nbaohuqi / nbaohuqijihua) * 100;
            }

            Conn.Close();
            Reader.Dispose();
            Cmd.Dispose();
            Conn.Dispose();
        }

        protected void Button_Save_Click(object sender, EventArgs e)
        {
            InitializeWorkbook();
            HSSFSheet sheet1 = hssfworkbook.GetSheet("月份入库量统计快报");
            Button_Query_Click(null, null);
            sheet1.GetRow(0).GetCell(0).SetCellValue(this.Month.SelectedItem.Text + "月份入库量统计快报");
            sheet1.GetRow(2).GetCell(2).SetCellValue((ntaojihua + nyoujihua) / 10000);
            sheet1.GetRow(2).GetCell(3).SetCellValue(0);
            sheet1.GetRow(2).GetCell(4).SetCellValue(ytaojihua + yyoujihua);
            sheet1.GetRow(2).GetCell(5).SetCellValue(yyou + ytao);
            sheet1.GetRow(2).GetCell(6).SetCellValue(((nyou + ntao) / 10000).ToString("0.000"));
            sheet1.GetRow(2).GetCell(7).SetCellValue(油套管月完成率.ToString("0.00"));
            sheet1.GetRow(2).GetCell(8).SetCellValue(0);
            sheet1.GetRow(2).GetCell(9).SetCellValue(油套管年完成率.ToString("0.00"));

            sheet1.GetRow(3).GetCell(2).SetCellValue(nyoujihua / 10000);
            sheet1.GetRow(3).GetCell(3).SetCellValue(0);
            sheet1.GetRow(3).GetCell(4).SetCellValue(yyoujihua);
            sheet1.GetRow(3).GetCell(5).SetCellValue(yyou);
            sheet1.GetRow(3).GetCell(6).SetCellValue((nyou / 10000).ToString("0.000"));
            sheet1.GetRow(3).GetCell(7).SetCellValue(油管月完成率.ToString("0.00"));
            sheet1.GetRow(3).GetCell(8).SetCellValue(0);
            sheet1.GetRow(3).GetCell(9).SetCellValue(油管年完成率.ToString("0.00"));

            sheet1.GetRow(4).GetCell(2).SetCellValue(ntaojihua / 10000);
            sheet1.GetRow(4).GetCell(3).SetCellValue(0);
            sheet1.GetRow(4).GetCell(4).SetCellValue(ytaojihua);
            sheet1.GetRow(4).GetCell(5).SetCellValue(ytao);
            sheet1.GetRow(4).GetCell(6).SetCellValue((ntao / 10000).ToString("0.000"));
            sheet1.GetRow(4).GetCell(7).SetCellValue(套管月完成率.ToString("0.00"));
            sheet1.GetRow(4).GetCell(8).SetCellValue(0);
            sheet1.GetRow(4).GetCell(9).SetCellValue(套管年完成率.ToString("0.00"));

            sheet1.GetRow(5).GetCell(2).SetCellValue(一分厂年计划 / 10000);
            sheet1.GetRow(5).GetCell(3).SetCellValue(0);
            sheet1.GetRow(5).GetCell(4).SetCellValue(一分厂月计划);
            sheet1.GetRow(5).GetCell(5).SetCellValue(y1tao);
            sheet1.GetRow(5).GetCell(6).SetCellValue((n1tao / 10000).ToString("0.000"));
            sheet1.GetRow(5).GetCell(7).SetCellValue(一分厂月完成率.ToString("0.00"));
            sheet1.GetRow(5).GetCell(8).SetCellValue(0);
            sheet1.GetRow(5).GetCell(9).SetCellValue(一分厂年完成率.ToString("0.00"));

            sheet1.GetRow(6).GetCell(2).SetCellValue(二分厂年计划 / 10000);
            sheet1.GetRow(6).GetCell(3).SetCellValue(0);
            sheet1.GetRow(6).GetCell(4).SetCellValue(二分厂月计划);
            sheet1.GetRow(6).GetCell(5).SetCellValue(y2you + y2tao);
            sheet1.GetRow(6).GetCell(6).SetCellValue(((n2you + n2tao) / 10000).ToString("0.000"));
            sheet1.GetRow(6).GetCell(7).SetCellValue(二分厂月完成率.ToString("0.00"));
            sheet1.GetRow(6).GetCell(8).SetCellValue(0);
            sheet1.GetRow(6).GetCell(9).SetCellValue(二分厂年完成率.ToString("0.00"));

            sheet1.GetRow(7).GetCell(2).SetCellValue(五分厂年计划 / 10000);
            sheet1.GetRow(7).GetCell(3).SetCellValue(0);
            sheet1.GetRow(7).GetCell(4).SetCellValue(五分厂月计划);
            sheet1.GetRow(7).GetCell(5).SetCellValue(y5you);
            sheet1.GetRow(7).GetCell(6).SetCellValue((n5you / 10000).ToString("0.000"));
            sheet1.GetRow(7).GetCell(7).SetCellValue(五分厂月完成率.ToString("0.00"));
            sheet1.GetRow(7).GetCell(8).SetCellValue(0);
            sheet1.GetRow(7).GetCell(9).SetCellValue(五分厂年完成率.ToString("0.00"));

            sheet1.GetRow(8).GetCell(2).SetCellValue(ntjiegujihua);
            sheet1.GetRow(8).GetCell(3).SetCellValue(0);
            sheet1.GetRow(8).GetCell(4).SetCellValue(ytjiegujihua);
            sheet1.GetRow(8).GetCell(5).SetCellValue(ytjiegu);
            sheet1.GetRow(8).GetCell(6).SetCellValue(ntjiegu);
            sheet1.GetRow(8).GetCell(7).SetCellValue(套管接箍月完成率.ToString("0.00"));
            sheet1.GetRow(8).GetCell(8).SetCellValue(0);
            sheet1.GetRow(8).GetCell(9).SetCellValue(套管接箍年完成率.ToString("0.00"));

            sheet1.GetRow(9).GetCell(2).SetCellValue(nyjiegujihua);
            sheet1.GetRow(9).GetCell(3).SetCellValue(0);
            sheet1.GetRow(9).GetCell(4).SetCellValue(yyjiegujihua);
            sheet1.GetRow(9).GetCell(5).SetCellValue(yyjiegu);
            sheet1.GetRow(9).GetCell(6).SetCellValue(nyjiegu);
            sheet1.GetRow(9).GetCell(7).SetCellValue(油管接箍月完成率.ToString("0.00"));
            sheet1.GetRow(9).GetCell(8).SetCellValue(0);
            sheet1.GetRow(9).GetCell(9).SetCellValue(油管接箍年完成率.ToString("0.00"));

            sheet1.GetRow(10).GetCell(2).SetCellValue(nbaohuqijihua);
            sheet1.GetRow(10).GetCell(3).SetCellValue(0);
            sheet1.GetRow(10).GetCell(4).SetCellValue(ybaohuqijihua);
            sheet1.GetRow(10).GetCell(5).SetCellValue(ybaohuqi);
            sheet1.GetRow(10).GetCell(6).SetCellValue(nbaohuqi);
            sheet1.GetRow(10).GetCell(7).SetCellValue(保护器月完成率.ToString("0.00"));
            sheet1.GetRow(10).GetCell(8).SetCellValue(0);
            sheet1.GetRow(10).GetCell(9).SetCellValue(保护器年完成率.ToString("0.00"));

            WriteToFile();
            Response.End();
        }

       
    }
}
